package com.ct.book.enums;

import lombok.Getter;
import lombok.Setter;

public enum BookStatus {
    DELETED(0, "无效"),
    NORMAL(1, "可借阅"),
    FORBIDDEN(2, "不可借阅");

    @Getter @Setter
    private Integer code;
    @Getter @Setter
    private String name;

    BookStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static BookStatus getNameByCode (Integer code) {
        switch (code) {
            case 0: return DELETED;
            case 1: return NORMAL;
            case 2: return FORBIDDEN;
        }
        return null;
    }
}
